package com.d16_Socket_Homework.homework2;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class ClientDemo1_TCP {
    public static void main(String[] args) throws IOException {
        //创建发送端Socket对象，指定ip地址和目的地端口号
        Socket  socket = new Socket("127.0.0.1",7777);
        Scanner sc = new Scanner(System.in);
        System.out.println("客户端发送：");
        while (true){
            //输出流写数据
            OutputStream os = socket.getOutputStream();
            String s = sc.nextLine();
            //结束标记
            if(s.equals("886")){
                socket.shutdownOutput();
                break;
            }
            os.write(s.getBytes());
        }
    }
}
